package com.example.controller;

import com.example.dto.PageDTO;
import com.example.dto.ReportDTO;
import com.example.query.PageQuery;
import com.example.query.ReportQuery;
import com.example.result.Result;
import com.example.service.IReportService;
import com.example.vo.ReportVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/report")
@Slf4j
@RequiredArgsConstructor
public class ReportController {

    private final IReportService reportService;

    /*
    * 新增举报
    * @param reportDTO
    * @return
    * */
    @PostMapping("/add")
    public Result addReport(@RequestBody ReportDTO reportDTO) {
        log.info("新增举报"+reportDTO);
        reportService.addReport(reportDTO);
        return Result.success();
    }
    /*
    * 获取举报列表
    * @param reportQuery
    * @return
    * */
    @GetMapping("/page")
    public Result<PageDTO<ReportVO>> QueryReportpage(ReportQuery reportQuery) {
        log.info("获取举报列表"+reportQuery);
        return reportService.QueryReportpage(reportQuery);
    }
    /*
    * 审核举报
    * @param id
    * @return
    * */
    @PutMapping
    public Result checkReport(@RequestBody ReportDTO reportDTO) {
        log.info("审核举报"+reportDTO);
        reportService.checkReport(reportDTO);
        return Result.success();
    }

    /*
    * 查询举报详细信息
    * @param id
    * @return
    * */
    @GetMapping("/{id}")
    public Result<ReportVO> QueryById(@PathVariable Long id) {
        log.info("查询举报详细信息"+id);
        ReportVO reportVO = reportService.getDetails(id);
        return Result.success(reportVO);
    }
}
